<template>
	<view class="activity">
		<view class="activity-list">
			<view class="activity-item" v-for="(data,index) in list" :key="index">
				<view class="activity-item-tag" v-if="data.status==1">已开启</view>
				<view class="activity-item-image"><image mode="aspectFill" :src="data.cover_img"></image></view>
				<view class="activity-item-info">
					<view class="activity-name">{{data.title}}</view>
					<view class="activity-btn">
						<text class="activity-btn-1" @click="goInfo(data)">比赛列表</text>
						<text class="activity-btn-2" @click="goRule(data)">规则设置</text>
					</view>
				</view>
			</view>
		</view>
		<loading v-if="isLoading"></loading>
		<no-more text='没有更多了' v-if="noMore && list.length"></no-more>
		<nothing :btn="false" text="暂无活动" v-if="!list.length"></nothing>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 0,
				list: [],
				isLoading: false,
				noMore: false
			};
		},
		onLoad() {
			this.init()
		},
		onReachBottom() {
			if(!this.noMore){
				this.page++
				this.isLoading = true
				this.init()
			}
		},
		methods: {
			init(){
				this.$api.MatchActivityList({page: this.page}).then(res => {
					this.isLoading = false
					if(res.datas.list.length){
						res.datas.list.forEach(item => {
							this.list.push(item)
						})
					}else{
						this.noMore = true
					}
				})
			},
			goInfo(data){
				uni.navigateTo({
					animationDuration: 500,
					url: '/pages/activity/activity-info?rule_id='+data.rule_id
				})
			},
			goRule(data){
				uni.navigateTo({
					animationDuration: 500,
					url: '/pages/activity/activity-rule?activity_id='+data.activity_id
				})
			},
		}
	}
</script>

<style lang="scss">
	.activity-list{
		padding: 30rpx 30rpx 0;
	}
	.activity-item{
		position: relative;
		background-color: #FFF;
		border-radius: 8rpx;
		.activity-item-tag{
			padding: 0 10rpx;
			height: 44rpx;
			line-height: 44rpx;
			color: #fff;
			background-color: #2174F5;
			position: absolute;
			border-radius: 8rpx 0 0 0;
			font-size: 22rpx;
			top: 0;
			left: 0;
			z-index: 1;
			&::after{
				content: '';
				width: 35rpx;
				height: 44rpx;
				position: absolute;
				transform: skewX(-30deg);
				background: #2174F5;
				top: 0;
				right: -15rpx;
				z-index: -1;
				border-top-right-radius: 8rpx;
			}
		}
		.activity-item-image{
			image{
				width: 100%;
				height: 340rpx;
				border-radius: 8rpx 8rpx 0 0;
			}
		}
		.activity-item-info{
			height: 110rpx;
			display: flex;
			padding: 0 20rpx;
			justify-content: space-between;
			align-items: center;
			.activity-name{
				font-size: 32rpx;
				font-weight: bold;
			}
			.activity-btn{
				text{
					display: inline-block;
					height: 48rpx;
					line-height: 44rpx;
					width: 120rpx;
					border-radius: 4rpx;
					font-size: 24rpx;
					text-align: center;
					vertical-align: top;
					&.activity-btn-1{
						border: solid 2rpx #E6E6E6;
						color: #4D4D4D;
						margin-right: 30rpx;
					}
					&.activity-btn-2{
						border: solid 2rpx #2174F5;
						background-color: #2174F5;
						color: #FFF;
					}
				}
			}
		}
	}
</style>
